import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * User:xieChao
 * Date:2022/10/20 12:53
 */


class Node {
    int val;
    Node next;
    Node random;

    public Node(int val) {
        this.val = val;
        this.next = null;
        this.random = null;
    }
}


public class Test1 {
    /**
     * 拷贝带随机指针的链表
     */
    public Node copyRandomList(Node head) {
        Map<Node,Node> map = new HashMap<>();
        Node cur = head;
        //第一遍 遍历
        while(cur != null){
            Node node = new Node(cur.val);
            map.put(cur,node);
            cur = cur.next;
        }
        //第二遍 遍历
        cur = head;
        while(cur != null){
            map.get(cur).next = map.get(cur.next);
            map.get(cur).random = map.get(cur.random);
            cur = cur.next;
        }
        return map.get(head);
    }

    /**
     * 宝石与石头问题
     * @param jewels
     * @param stones
     * @return
     */

    public int numJewelsInStones(String jewels, String stones) {
        Set<Character> set = new HashSet<>();
        int count = 0;
        //先把宝石遍历 add进来
        for(Character str : jewels.toCharArray()){
            set.add(str);
        }
        //再遍历石头，如果和宝石重复，计数器加1
        for(Character ch : stones.toCharArray()){
            if(set.contains(ch)){
                count++;
            }
        }
        return count;
    }


    /**
     * 旧键盘问题
     * @param want
     * @param real
     */
    public static void func(String want,String real){
        Set<Character> set = new HashSet<>();
        for(Character ch : real.toUpperCase().toCharArray()){
            set.add(ch);
        }
        Set<Character> setbroken = new HashSet<>();

        for(char str : want.toUpperCase().toCharArray()){
            if(!set.contains(str) && !setbroken.contains(str)){
                System.out.print(str);
                setbroken.add(str);
            }
        }
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String want = sc.nextLine();
        String real = sc.nextLine();
        func(want,real);
    }


    /**
     * 前K个高频单词
     * @param words
     * @param k
     * @return
     * Key:单词
     * Value:频率
     */


    public List<String> topKFrequent(String[] words, int k) {
        HashMap<String,Integer> map = new HashMap<>();
        //1.统计每个单词出现的次数  map
        for (String s:words) {
            if(map.get(s) == null){
                map.put(s,1);
            }else{
                int val = map.get(s);
                map.put(s,val+1);
            }
        }



        //2.建立一个大小为 k 的小根堆
        PriorityQueue<Map.Entry<String,Integer>> minHeap = new PriorityQueue<>(k, new Comparator<Map.Entry<String, Integer>>() {
            @Override
            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                if(o1.getValue().compareTo(o2.getValue()) == 0){
                    return o2.getKey().compareTo(o1.getKey());
                }
                return o1.getValue() - o2.getValue();
            }
        });


        //3.遍历map
        for (Map.Entry<String,Integer> entry:map.entrySet()) {
           if(minHeap.size() < k){
               minHeap.offer(entry);//入堆
           }else{
               //此时堆中已经放满了k个元素，需要看堆顶元素的数据 和当前数据的大小关系
               Map.Entry<String,Integer> top = minHeap.peek();
               //判断频率是否相同，如果相同，比较单词大小，单词小的 入堆
               if(top.getValue().compareTo(entry.getValue()) == 0){
                   if(top.getKey().compareTo(entry.getKey()) > 0){
                       minHeap.poll();
                       minHeap.offer(entry);
                   }
               }else{
                   if(top.getValue().compareTo(entry.getValue()) < 0){
                       minHeap.poll();
                       minHeap.offer(entry);
                   }
               }
           }
        }
        System.out.println(minHeap);
        List<String> ret = new ArrayList<>();
        for(int i = 0;i < k;i++){
            Map.Entry<String,Integer> top = minHeap.poll();
            ret.add(top.getKey());
        }
        Collections.reverse(ret);
        return ret;
    }


}
